package net.xiduth.game.player.dialogues.impl;

import net.xiduth.game.Animation;
import net.xiduth.game.ForceTalk;
import net.xiduth.game.Graphics;
import net.xiduth.game.World;
import net.xiduth.game.WorldTile;
import net.xiduth.game.npc.NPC;
import net.xiduth.game.player.dialogues.Dialogue;
import net.xiduth.utils.ShopsHandler;
import net.xiduth.utils.npc.DialAnims;

public class Aubury extends Dialogue {

	int npcId;

	public NPC findNPC(int id) {
		for (NPC npc : World.getNPCs()) {
			if (npc == null || npc.getId() != id)
				continue;
			return npc;
		}
		return null;
	}

	@Override
	public void start() {
		npcId = (Integer) parameters[0];
		sendNPCDialogue(npcId, DialAnims.HAPPY_TALKING.getId(), "Do you want to buy some runes?");
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "Yes, please.", "Oh, it's a rune shop. No, thank you.", "Can you teleport me to the rune essence?");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				ShopsHandler.openShop(player, 11);
				end();
				break;
			case OPTION_2:
				sendPlayerDialogue(NO_EXPRESSION, "Oh, it's a rune shop. No, thank you.");
				stage = 1;
				break;
			case OPTION_3:
				sendPlayerDialogue(CALM_TALKING, "Can you teleport me to the rune essence?");
				stage = 2;
				break;
			}
			break;
		case 2:
			NPC aubury = findNPC(5913);
			aubury.setNextForceTalk(new ForceTalk("Senventior disthine molenko!"));
			aubury.setNextAnimation(new Animation(1818));
			aubury.faceEntity(player);
			World.sendProjectile(aubury, player, 110, 1, 1, 1, 1, 1, 1);
			player.setNextGraphics(new Graphics(110));
			player.setNextWorldTile(new WorldTile(2910, 4832, 0));
			end();
			break;
		case 1:
			sendNPCDialogue(npcId, CALM_TALKING, "Well, if you find someone who wants runes, please send them my way.");
			stage = -2;
			break;
		default:
			end();
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub

	}

}
